//
//  ScrollView.swift
//  CooperSwift
//
//  Created by 计海峰 on 2021/11/19.
//

import Foundation

public extension UIScrollView {
    
    /// 内容截图
   func contentScreenshot() -> UIImage? {
        let oldFrame = layer.frame
        let oldSize = contentSize
        UIGraphicsBeginImageContextWithOptions(oldSize, false, UIScreen.main.scale)
        layer.frame = CGRect(0, 0, oldSize.width, oldSize.height)
        guard let context = UIGraphicsGetCurrentContext() else { return nil }
        layer.render(in: context)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        layer.frame = oldFrame
        return image
   }
    
    /// 1、移除顶部距离
    func defaultConfig() -> Void {
        contentInsetAdjustmentBehavior = .never
    }
    
}
